<template>
	<view v-if="data !== undefined && data!== null && data.length>0">
		<u-cell-group>
			<u-cell :title="item.name" isLink @click="policy(item.id)" v-for="(item,index) in data" :key="index">
				<u-icon slot="icon" size="30" color="#a0cfff" name="coupon"></u-icon>
			</u-cell>
		</u-cell-group>
	</view>
	<u-empty v-else mode="data" icon="/static/Empty/data_null.png" text="您还没有代理产品哦">
	</u-empty>
</template>

<script>
	export default {
		data() {
			return {
				data: []
			}
		},
		onLoad() {
			this._request()
		},
		methods: {
			async _request() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Setting/getMyProduct',
					// data: {},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					this.data = res.data
					if (this.data.length == 1) {
						this.policy(this.data[0].id)
					}
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 3000
					})
				}
			},
			policy(id) {
				uni.navigateTo({
					url: '/pages/version5/index/SetPolicy/Info?id=' + id
				})
			}
		}
	}
</script>

<style>

</style>